//
//  GTRecommandViewController.m
//  ScrollViewStudy
//
//  Created by Jason Len on 2019/9/5.
//  Copyright © 2019年 Jason. All rights reserved.
//

#import "GTRecommandViewController.h"

@interface GTRecommandViewController ()

@end

@implementation GTRecommandViewController

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.tabBarItem.title=@"推荐";
        self.tabBarItem.image=[UIImage imageNamed:@"icon.bundle/like@2x.png"];
        self.tabBarItem.selectedImage=[UIImage imageNamed:@"icon.bundle/like_selected@2x.png"];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor yellowColor];
    
    //初始化screen 的屏幕大小
    UIScrollView *scrollView =  [[UIScrollView alloc]initWithFrame:self.view.bounds];

    //设置内容尺寸大小
    scrollView.contentSize = CGSizeMake(self.view.bounds.size.width*5, self.view.bounds.size.height);
    scrollView.backgroundColor = [UIColor grayColor];
    scrollView.showsHorizontalScrollIndicator = YES;
    scrollView.pagingEnabled = YES;
    
    NSArray *colorArray = @[[UIColor blueColor], [UIColor greenColor], [UIColor redColor],[UIColor grayColor],[UIColor yellowColor]];
    for(int i=0; i<5; i++){
        [scrollView addSubview:({
            UIView *view = [[UIView alloc]initWithFrame:CGRectMake(self.view.frame.size.width * i, 0, self.view.frame.size.width, self.view.frame.size.height)];
            view.backgroundColor = [colorArray objectAtIndex:i];
            view;
        })];
    }
    
    scrollView.delegate = self;
    
    [self.view addSubview:scrollView];
    
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    
//    NSLog(@"didScroll-%@",@(scrollView.contentOffset.x));
    
}

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
    NSLog(@"begin dragging");
}


- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
     NSLog(@"end dragging");
}

- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{
     NSLog(@"begin decelerating");
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    NSLog(@"end decelerating");
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
